/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 *
 */

import { initByFAEmptyApp, initByFAEmptyService, initByStageEmptyApp, initByStageEmptyService } from './common/common';
import { testPreviewForService, testPreviewResource } from './common/task/common-preview';

describe('test Preview FA app', () => {
  test.concurrent('fa app entry preview', async () => {
    await initByFAEmptyApp(async (projectDir) => {
      testPreviewResource(projectDir, 'entry',
        ['previewer.replace.srcPath=PageAbility', 'previewer.replace.page=pages/index']);
    });
  });

  test.concurrent('fa app feature preview', async () => {
    await initByFAEmptyApp(async (projectDir) => {
      testPreviewResource(projectDir, 'feature');
    });
  });

  test.concurrent('fa app library preview', async () => {
    await initByFAEmptyApp(async (projectDir) => {
      testPreviewResource(projectDir, 'library');
    });
  });

  test.concurrent('fa app library1 preview', async () => {
    await initByFAEmptyApp(async (projectDir) => {
      testPreviewResource(projectDir, 'library1');
    });
  });
});

describe('test Preview FA service', () => {
  test.concurrent('fa service entry preview', async () => {
    await initByFAEmptyService(async (projectDir) => {
      testPreviewResource(projectDir, 'entry');
    });
  });

  test.concurrent('fa service feature preview', async () => {
    await initByFAEmptyService(async (projectDir) => {
      testPreviewResource(projectDir, 'feature');
    });
  });

  test.concurrent('fa service library preview', async () => {
    await initByFAEmptyService(async (projectDir) => {
      testPreviewResource(projectDir, 'library');
    });
  });

  test.concurrent('fa service library1 preview', async () => {
    await initByFAEmptyService(async (projectDir) => {
      testPreviewResource(projectDir, 'library1');
    });
  });
});

describe('test Preview Stage app', () => {
  test.concurrent('stage app entry preview', async () => {
    await initByStageEmptyApp(async (projectDir) => {
      testPreviewResource(projectDir, 'entry');
    },);
  });

  test.concurrent('stage app feature preview', async () => {
    await initByStageEmptyApp(async (projectDir) => {
      testPreviewResource(projectDir, 'feature');
    });
  });

  test.concurrent('stage app library preview', async () => {
    await initByStageEmptyApp(async (projectDir) => {
      testPreviewResource(projectDir, 'library');
    });
  });

  test.concurrent('stage app library1 preview', async () => {
    await initByStageEmptyApp(async (projectDir) => {
      testPreviewResource(projectDir, 'library1');
    });
  });
});

describe('test Preview Stage service', () => {
  test.concurrent('stage service entry preview', async () => {
    await initByStageEmptyService(async (projectDir) => {
      testPreviewForService(projectDir, 'entry');
    });
  });

  test.concurrent('stage service feature preview', async () => {
    await initByStageEmptyService(async (projectDir) => {
      testPreviewForService(projectDir, 'feature');
    });
  });

  test.concurrent('stage service library preview', async () => {
    await initByStageEmptyService(async (projectDir) => {
      testPreviewForService(projectDir, 'library');
    });
  });

  test.concurrent('stage service library1 preview', async () => {
    await initByStageEmptyService(async (projectDir) => {
      testPreviewForService(projectDir, 'library1');
    });
  });
});
